using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

using Microsoft.Crm.Sdk;
using Microsoft.Crm.Sdk.Query;
using Microsoft.Crm.SdkTypeProxy;
using Microsoft.Crm.Sdk.Metadata;
using Microsoft.Crm.SdkTypeProxy.Metadata;


namespace winCRM4QueryBuilder
{
    public partial class frmCRM4XMLQueryBuilderAttributeLK : Form
    {
       private frmCRM4XMLQueryBuilder myform1;

        public frmCRM4XMLQueryBuilderAttributeLK()
        {
            InitializeComponent();
        }

        public frmCRM4XMLQueryBuilderAttributeLK(EntityMetadata myentitymetadata, frmCRM4XMLQueryBuilder myparentform)
        {
            InitializeComponent();
            this.myform1 = myparentform;
            foreach (AttributeMetadata attributeMetadata in myentitymetadata.Attributes)
            {
                this.checkedListBox1.Items.Add(attributeMetadata.LogicalName.ToString(), false);
            }
        }



        public EntityMetadata myentitymetadata;

        private void btnFinishSelection_Click(object sender, EventArgs e)
        {
            ArrayList myarraylist = new ArrayList();
            for (int x = 0; x <= checkedListBox1.CheckedItems.Count - 1; x++){
                myarraylist.Add(checkedListBox1.CheckedItems[x].ToString());
            }
            this.myform1.myTreeArrayList = myarraylist;
            this.myform1.UpdateTree();
            this.Dispose();
        }
    }
}